<@>layout("/common/default.html"){
<div class="x-body">
    <form class="layui-form" id="job-data">
        <div class="layui-form-item">
            <label class="layui-form-label">任务名称：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="required" class="layui-input" id="jobName" name="jobName"
                       value="${jobAndTrigger.jobName}" style="width: 95%">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">任务分组：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="required" class="layui-input" id="jobGroup" name="jobGroup"
                       value="${jobAndTrigger.jobGroup}" style="width: 95%">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">表达式：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="required" class="layui-input" id="cronExpression" name="cronExpression"
                       value="${jobAndTrigger.cronExpression}" style="width: 95%">
            </div>
        </div>
        <div class="layui-form-item">
            <@>if (isEmpty(jobAndTrigger.jobName)){
            <button type="button" onclick="saveJob();" class="layui-btn" style="position: relative;left: 40px">提交</button>
            <@>} else {
            <button type="button" onclick="updateJob();" class="layui-btn" style="position: relative;left: 40px">修改</button>
            <@>}
        </div>
    </form>
</div>
<script>
    function saveJob() {
        $.cajax('${ctxPath}/ajax/system/job/save', $('#job-data').serialize(), function (r) {
            var code = r.code;
            var msg = r.msg;
            if (code == '1') {
                $.msg(msg, function () {
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layui.table.reload('job-list');
                    parent.layer.close(index); //再执行关闭
                }, code);
            } else {
                $.msg(msg, function () {
                }, 2);
            }
        });
    }

    function updateJob() {
        $.cajax('${ctxPath}/ajax/system/job/update', $('#job-data').serialize(), function (r) {
            var code = r.code;
            var msg = r.msg;
            if (code == '1') {
                $.msg(msg, function () {
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layui.table.reload('job-list');
                    parent.layer.close(index); //再执行关闭
                }, code);
            } else {
                $.msg(msg, function () {
                }, 2);
            }
        });
    }
</script>
<@>}